package com.bong.panpan.bongcharttools.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.bong.panpan.bongcharttools.fragment.DeviceFragment;
import com.bong.panpan.bongcharttools.fragment.ScanFragment;

/**
 * Created by panpan on 2017/10/25.
 */

public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter {
    final int PAGE_COUNT = 2;
    public static int count=0;
    private String tabTitles[] = new String[]{"扫描设备","已连接设备"};
    private Context context;
    private Fragment[] fragments=new Fragment[2];

    public SimpleFragmentPagerAdapter(FragmentManager fm, Context context) {
        super(fm);
        this.context = context;
        fragments[0]= ScanFragment.newInstance("","");
        fragments[1]= DeviceFragment.newInstance("","");
    }

    @Override
    public Fragment getItem(int position) {
        return fragments[position];
    }

    @Override
    public int getCount() {
        return fragments.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if(position==1)
            return tabTitles[1]+"("+count+")";
        return tabTitles[position];
    }
    public Fragment[] getFragments() {
        return fragments;
    }
}
